package com.pri.chat.utils.fileutils;

import android.os.Environment;

import java.io.File;

public class FileUtils {
    public static final String ROOT_PATH = Environment.getExternalStorageDirectory()+"/com.pri.chat/cache/video/";
    //判断是否安装SDCard
    public static boolean isSdOk(){
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
            return true;
        }
        return false;
    }
    //创建一个文件夹，用来存放下载的文件
    public static File getRootFile(){
        File rootFile = new File(ROOT_PATH);
        if (!rootFile.exists()){
            rootFile.mkdirs();
        }
        return rootFile;
    }

    public static File getFinishFile(String name){
        String path = ROOT_PATH+name.replace("mp4","");
        File rootFile = new File(path);
        return rootFile;
    }

    public static boolean isDownLoadSuccess(String urlPath){
        String path = ROOT_PATH+urlPath.substring(urlPath.lastIndexOf("/") + 1).replace("mp4","");;
        File rootFile = new File(path);
        return rootFile.exists();
    }
}